package main

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"
)

func main() {
	appPath, _ := filepath.Abs(filepath.Dir(os.Args[0]))
	if strings.Contains(appPath, "_test") {
		//处于go test状态下
		goPath := os.Getenv("GOPATH")
		wd, _ := os.Getwd()

		if strings.Contains(wd, "go-api-server") {
			appPath = filepath.Join(goPath, "/src/yingsheng.com/go-api-server/example")
		} else {
			wds := strings.Split(wd, "/")
			for i, l := 0, len(wds); i < l; i++ {
				if strings.EqualFold(wds[i], "yingsheng.com") {
					appPath = filepath.Join(goPath, "/src/yingsheng.com", wds[i+1])
					break
				}
			}
		}
	}
	fmt.Println("appPath:", appPath)
}
